'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: study_str.py
* @Time: 2025/6/15
* @All Rights Reserve By Brtc
'''
"""字符串的学习"""
# 目前市面上的 90%  代码都是在做 字符串 处理s
str_a = "hello world"
print(dir(str_a))

"""
['__add__', '__class__', '__contains__', '__delattr__', 
'__dir__', '__doc__', '__eq__', '__format__', '__ge__', 
'__getattribute__', '__getitem__', '__getnewargs__', '__getstate__', '__gt__', 
'__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', 
'__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', 
'__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 
'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 
'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 
'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 
'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
"""
str_uppper = "ABCDEF"
print(f"{str_uppper} to_lower {str_uppper.lower()}")# 转成小写

str_split = "1,2,3,4,5,6,7"
print(f"{str_split} to_split {str_split.split(',')}") # 分割

str_cotent = "你好我是  吴彦祖，我今年18岁"
print(f"{str_cotent} 是否包含 吴彦祖 ，{str_cotent.__contains__("吴彦祖")} ") # 是否包含

# 转义学习"hello\nword"

print("Hello\nworld")
print("Hello\tworld")
print("Hello\bworld")
print("Hello\\nworld")

# 格式话输出
var_name = "吴彦祖"
var_age = 18
var_weight = 208
print("大家好我的名字叫： " + var_name + "今年 " + str(var_age) + "岁 体重" + str(var_weight) + "斤~！！")

var_format = "大家好我的名字叫{}，今年{}岁，体重是{}斤".format(var_name, var_age, var_weight)
print(var_format)

print(f"大家好我的名字叫{var_name}，今年{var_age}岁， 体重是{var_weight}斤")

# 查找指定字符串的位置
find_str = "Hello 123456  world"
print(find_str.find('H'))
print(find_str.find('123456'))
print(find_str.find('world'))

# 字符串替换
replace_str = "你好是我的 {role} 助手， 现在需要你将一个关于 {object} 的笑话"

print(replace_str.replace("{role}", "笑话").replace("{object}","测试开发"))
print(replace_str.replace("{role}", "翻译").replace("{object}","美国人"))